"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
console.log('-----2工厂方法模式-------');
//2.1 工厂方法模式
//咖啡的基类
var Coffe = /** @class */ (function () {
    function Coffe(name) {
        this.coffeName = name;
        this.getCoffe(this.coffeName);
        console.log('我是coffee的基类！！！');
    }
    Coffe.prototype.getCoffe = function (name) {
        console.log("\u5236\u4F5C\u7684\u662F" + name + "\u5496\u5561");
    };
    return Coffe;
}());
;
// 创建咖啡实例的类
var AmriCoffe = /** @class */ (function (_super) {
    __extends(AmriCoffe, _super);
    function AmriCoffe(name) {
        var _this = _super.call(this, name) || this;
        console.log('我是创建Amri咖啡实例的类');
        return _this;
    }
    return AmriCoffe;
}(Coffe));
var LatteCoffe = /** @class */ (function (_super) {
    __extends(LatteCoffe, _super);
    function LatteCoffe(name) {
        var _this = _super.call(this, name) || this;
        console.log('我是创建latte咖啡实例的类');
        return _this;
    }
    return LatteCoffe;
}(Coffe));
var FlowerCoffe = /** @class */ (function (_super) {
    __extends(FlowerCoffe, _super);
    function FlowerCoffe(name) {
        var _this = _super.call(this, name) || this;
        console.log('我是创建Flower咖啡实例的类');
        return _this;
    }
    return FlowerCoffe;
}(Coffe));
;
// 创建’创建咖啡实例类的工厂‘
var AmriCoffeFactory = /** @class */ (function (_super) {
    __extends(AmriCoffeFactory, _super);
    function AmriCoffeFactory(name) {
        var _this = _super.call(this, name) || this;
        _this.setCoffe(name);
        return _this;
    }
    AmriCoffeFactory.prototype.setCoffe = function (coffe) {
        new AmriCoffe(coffe);
    };
    return AmriCoffeFactory;
}(AmriCoffe));
var LatteCoffeFactory = /** @class */ (function (_super) {
    __extends(LatteCoffeFactory, _super);
    function LatteCoffeFactory(name) {
        var _this = _super.call(this, name) || this;
        _this.setCoffe(name);
        return _this;
    }
    LatteCoffeFactory.prototype.setCoffe = function (coffe) {
        new LatteCoffe(coffe);
    };
    return LatteCoffeFactory;
}(LatteCoffe));
var FlowerCoffeFactory = /** @class */ (function (_super) {
    __extends(FlowerCoffeFactory, _super);
    function FlowerCoffeFactory(name) {
        var _this = _super.call(this, name) || this;
        _this.setCoffe(name);
        return _this;
    }
    FlowerCoffeFactory.prototype.setCoffe = function (coffe) {
        new FlowerCoffe(coffe);
    };
    return FlowerCoffeFactory;
}(FlowerCoffe));
;
//工厂的基类
var Factory = /** @class */ (function () {
    function Factory(name) {
        console.log('我是工厂的基类！！！');
    }
    return Factory;
}());
;
var FactoryFn = /** @class */ (function (_super) {
    __extends(FactoryFn, _super);
    function FactoryFn(name) {
        return _super.call(this, name) || this;
    }
    ;
    //静态方法
    FactoryFn.order = function (coffeName) {
        switch (coffeName) {
            case '美式咖啡':
                return new AmriCoffeFactory(coffeName);
                break;
            case '拿铁咖啡':
                return new LatteCoffeFactory(coffeName);
                break;
            case '花式咖啡':
                return new FlowerCoffeFactory(coffeName);
                break;
            default:
                return 'sorry!我们这里没有这种咖啡！';
        }
    };
    return FactoryFn;
}(Factory));
// let res2 = FactoryFn.order('美式咖啡');
// new FactoryFn('hello ');
// console.log(res2);
// 2.2 工厂方法模式测试用例：raect中的例子
function createElement(type, config) {
    return { type: type, config: config };
}
;
function createFactory(type) {
    var factory = createElement.bind(null, type);
    return factory;
}
;
var factory1 = createFactory('h1');
var element = factory1({ id: '123456', calssName: 'title' });
console.log(element);
// }
